package com.tccmeta.matchmaker.config;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author Gentle
 * @date 2019/05/05
 * 微信支付信息注入bean 中
 */
@Component
public class WeChatPayConfig {
    private String appId = "wx7a5d21131e4696b3";
    private String secret="0b4b82441ca270c507befa6e1478e42c";
    private String token="vxZ4wisZdsBdRRdDdTXDHtZ4tsTBDDd0";
    private String mchId = "1614949306";
    private String mchKey = "privateKey1111111111111111111111";
    private String keyPath="classpath:wechat/apiclient_cert.p12";
    private String tradeType = "JSAPI";
    private String notifyUrl = "http://ys.52hz.love/api/wechat/pay/weChatPayNotify";
    @Bean
    @ConditionalOnMissingBean
    public WxPayConfig payConfig() {
        WxPayConfig payConfig = new WxPayConfig();
        payConfig.setAppId(appId);
        payConfig.setMchId(mchId);
        payConfig.setMchKey(mchKey);
        payConfig.setKeyPath(keyPath);
        payConfig.setTradeType(tradeType);
        payConfig.setNotifyUrl(notifyUrl);
        return payConfig;
    }
    @Bean
    public WxPayService wxPayService(WxPayConfig payConfig) {
        WxPayService wxPayService = new WxPayServiceImpl();
        wxPayService.setConfig(payConfig);
        return wxPayService;
    }
}
